home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / mgabra.zip / MGUN.ASM < prev    next >
Assembly Source File  |  1988-02-25  |  5KB  |  225 lines

  1. PAGE    55,132
  2. TITLE   ABRACADABRA! MAGIC SOFTWARE TSR/TCR (Terminate Cont Running) LIBRARY
  3.  
  4. DEINT   EQU     0E0h
  5.  
  6. INCLUDE MGLANGC.ASM
  7.  
  8. GETFARPTR MACRO
  9.         mov     ax, PARM1
  10.         mov     farptr[2], ax
  11.         mov     ax, PARM2
  12.         mov     farptr, ax
  13.         ENDM
  14.  
  15. ;------------------------------------------------
  16. ; DOC
  17. ; certain of these functions poll the tsr for
  18. ; data which is returned in the corresponding
  19. ; registers and then to the calling program
  20. ;
  21. ;       ax      process status
  22. ;       cx      process id number
  23. ;       bx,     environment
  24. ;       dx    code segment
  25. ;
  26. ;------------------------------------------------
  27.  
  28. ;------------------------------------------------
  29. ; SEGMENT DEFINITIONS
  30. ;------------------------------------------------
  31.  
  32. _BSS    SEGMENT WORD PUBLIC 'BSS'
  33. _BSS    ENDS
  34.  
  35. DGROUP  GROUP   _DATA, _BSS
  36. _DATA   SEGMENT WORD PUBLIC 'DATA'
  37.         ASSUME  DS:DGROUP, SS:DGROUP
  38. _DATA   ENDS
  39.  
  40. _TEXT   SEGMENT BYTE PUBLIC 'CODE'
  41.         ASSUME  CS:_TEXT
  42.  
  43.     PUBLIC    _tsrs
  44.     PUBLIC    _procid
  45.     PUBLIC    _firstsr
  46.     PUBLIC    _procst
  47.     PUBLIC  _nextsr
  48.     PUBLIC    _un
  49.     PUBLIC    _check
  50.  
  51. farcall  label  dword
  52. farptr   dw     2 dup(?)
  53.  
  54. hi    dw      0
  55. lo    dw    0
  56.  
  57. ;------------------------------------------------
  58. ; Publics
  59. ;------------------------------------------------
  60.  
  61. ;------------------------------------------------
  62. ; _TSRS - returns 1 if int E0 is non zero
  63. ;------------------------------------------------
  64.  
  65. _tsrs   proc    far
  66.         LANGIN
  67.         mov     bx, DEINT       ;our interrupt
  68.         mov     cl, 2
  69.         shl     bx, cl          ;times 4
  70.         mov     cx, 0
  71.         push    cx              ;load up es
  72.         pop     es
  73.         mov     ax, es:[bx]     ;get value and return
  74.         LANGRET 0
  75. _tsrs   endp
  76.  
  77. ;------------------------------------------------
  78. ; _procid - returns process id number
  79. ;------------------------------------------------
  80.  
  81. _procid proc    far
  82.         LANGIN
  83.     GETFARPTR
  84.         mov     ax, 1           ;execute function 1 (poll process)
  85.         call    farcall
  86.         RETVAL  cx              ;return the value in ax
  87.         LANGRET
  88. _procid endp
  89.  
  90. ;------------------------------------------------------
  91. ; _firstsr - returns address of first tsrs clear routine
  92. ;------------------------------------------------------
  93.  
  94. _firstsr proc   far
  95.         LANGIN
  96.         mov     ax, DEINT       ;our interrupt
  97.         mov     cl, 2
  98.         shl     ax, cl          ;times 4
  99.         mov     cx, 0
  100.         push    cx              ;load up es
  101.         pop     es
  102.     mov    bx, ax
  103.         mov     dx, es:[bx]     ;get vectors segment
  104.         mov     ax, es:[bx+2]   ;get vectors offset
  105.         LANGRET 0
  106. _firstsr endp
  107.  
  108. ;------------------------------------------------
  109. ; _nextsr(seg, off) of current tsr
  110. ;------------------------------------------------
  111.  
  112. _nextsr proc    far
  113.         LANGIN
  114.     GETFARPTR
  115.         mov     ax, 1           ;execute function 1 (poll process)
  116.         call    farcall
  117.         RETVAL  bx
  118.         RETHIGH dx
  119.         LANGRET 0
  120. _nextsr endp
  121.  
  122. ;------------------------------------------------
  123. ; _procst - return process status word
  124. ;------------------------------------------------
  125.  
  126. _procst proc    far
  127.         LANGIN
  128.     GETFARPTR
  129.         mov     ax, 1           ;execute function 1 (poll process)
  130.         call     farcall         ;returns status in ax
  131.         LANGRET                 ;value ends up in ax which is c's returner
  132. _procst endp
  133.  
  134. ;------------------------------------------------
  135. ; _un - deinstall the TSR
  136. ;------------------------------------------------
  137.  
  138. _un     proc    far
  139.         LANGIN
  140.     GETFARPTR
  141.         mov     ax, 0
  142.     call    farcall
  143.     sub    dx, PSPOFFSET
  144.         push    bx
  145.         push    dx
  146.         pop     es
  147.         mov     ah, 49h
  148.         int     21h
  149.         pop     es
  150.         mov     ah, 49h
  151.         int     21h
  152.     cmp    ax, 9
  153.     jg    un1
  154.     mov    ax, 0
  155. un1:
  156.         LANGRET 0
  157. _un     endp
  158.  
  159. ;------------------------------------------------
  160. ; _check - is requested tsr loaded?
  161. ;------------------------------------------------
  162.  
  163. _check    proc    far
  164.     push    bp
  165.     mov    bp,sp
  166.     sub    sp,6
  167.     call    far ptr _FIRSTSR
  168.     mov    word ptr [bp-2],dx
  169.     mov    word ptr [bp-4],ax
  170.     mov    hi, dx
  171.     mov    lo, ax
  172.  
  173. check2:
  174.  
  175.     mov    ax,word ptr [bp-4]
  176.     or    ax,word ptr [bp-2]
  177.     je    check3
  178.     push    word ptr [bp-2]
  179.     push    word ptr [bp-4]
  180.     call    far ptr _PROCID
  181.     pop    cx
  182.     pop    cx
  183.     mov    word ptr [bp-6],ax
  184.     mov    ax,word ptr [bp-6]
  185.     cmp    ax,word ptr [bp+6]
  186.     jne    check4
  187.     jmp    short check1
  188.  
  189. check4:
  190.  
  191.     mov    lo, 0
  192.     mov    hi, 0
  193.     push    word ptr [bp-2]
  194.     push    word ptr [bp-4]
  195.     call    far ptr _NEXTSR
  196.     pop    cx
  197.     pop    cx
  198.     mov    word ptr [bp-2],dx
  199.     mov    word ptr [bp-4],ax
  200.     mov    lo, ax
  201.     mov    hi, dx
  202.     jmp    short check2
  203.  
  204. check3:
  205.  
  206.     mov    lo, 0
  207.     mov    hi, 0
  208.  
  209. check1:
  210.  
  211.     mov    dx, hi
  212.     mov    ax, lo
  213.     mov    sp,bp
  214.     pop    bp
  215.     ret
  216. _check    endp
  217.  
  218. _TEXT   ENDS
  219.  
  220.         END
  221.  
  222. ;------------------------------------------------
  223. ; END OF MGUN.ASM
  224. ;------------------------------------------------
  225.